﻿// JSON C# Class Generator
// http://at-my-window.blogspot.com/?page=json-class-generator

using System;
using Newtonsoft.Json.Linq;
using BuscoPre;

namespace BuscoPre.Repository.MLA.JsonTypes
{

    public class Result
    {

        private JObject __jobject;
        public Result(JObject obj)
        {
            this.__jobject = obj;
        }

        public string Id
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "id"));
            }
        }

        public string SiteId
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "site_id"));
            }
        }

        public string Title
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "title"));
            }
        }

        public string Subtitle
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "subtitle"));
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Seller _seller;
        public Seller Seller
        {
            get
            {
                if(_seller == null)
                    _seller = JsonClassHelper.ReadStronglyTypedObject<Seller>(JsonClassHelper.GetJToken<JObject>(__jobject, "seller"));
                return _seller;
            }
        }

        public double Price
        {
            get
            {
                return JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(__jobject, "price"));
            }
        }

        public string CurrencyId
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "currency_id"));
            }
        }

        public int SoldQuantity
        {
            get
            {
                return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "sold_quantity"));
            }
        }

        public string BuyingMode
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "buying_mode"));
            }
        }

        public string ListingTypeId
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "listing_type_id"));
            }
        }

        public string StopTime
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "stop_time"));
            }
        }

        public string Condition
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "condition"));
            }
        }

        public string Permalink
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "permalink"));
            }
        }

        public string Thumbnail
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "thumbnail"));
            }
        }

        public bool AcceptsMercadopago
        {
            get
            {
                return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "accepts_mercadopago"));
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Installments _installments;
        public Installments Installments
        {
            get
            {
                if(_installments == null)
                    _installments = JsonClassHelper.ReadStronglyTypedObject<Installments>(JsonClassHelper.GetJToken<JObject>(__jobject, "installments"));
                return _installments;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Address _address;
        public Address Address
        {
            get
            {
                if(_address == null)
                    _address = JsonClassHelper.ReadStronglyTypedObject<Address>(JsonClassHelper.GetJToken<JObject>(__jobject, "address"));
                return _address;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private object[] _attributes;
        public object[] Attributes
        {
            get
            {
                if(_attributes == null)
                    _attributes = (object[])JsonClassHelper.ReadArray<object>(JsonClassHelper.GetJToken<JArray>(__jobject, "attributes"), JsonClassHelper.ReadObject, typeof(object[]));
                return _attributes;
            }
        }

    }
}
